import { Global, Logger, Module } from '@nestjs/common';
import { UserModule } from './user/user.module';
import { ConfigModule } from '@nestjs/config';
import * as dotenv from 'dotenv';
import * as Joi from 'joi';
import { TypeOrmModule } from '@nestjs/typeorm';

import { LogsModule } from './logs/logs.module';
import { RolesModule } from './roles/roles.module';

import { connectionParams } from '../ormconfig';
import { AuthModule } from './auth/auth.module';
import { OssModule } from './oss/oss.module';
import { BizModule } from './bizAccount/biz.module';
import { BizQualificationModule } from './bizQualification/bizQualificationModule';
import { AppVersionModule } from './appVersion/app.version.module';

const envFilePath = `.env.${process.env.NODE_ENV || `development`}`;

@Global()
@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath,
      load: [() => dotenv.config({ path: '.env' })],
    }),
    TypeOrmModule.forRoot(connectionParams),
    UserModule,
    LogsModule,
    RolesModule,
    AuthModule,
    OssModule,
    BizModule,
    BizQualificationModule,
    AppVersionModule,
  ],
  controllers: [],
  providers: [Logger],
  exports: [Logger],
})
export class AppModule {
}
